public class binary_search {
    private static Integer binary_search(int[] array, int item) {
        int low = 0;
        int high = array.length - 1;
        while (low <= high) {
            int mid = (low + high) / 2;
            int guess = array[mid];
            if (guess == item)
                return mid;
            else if (guess > item)
                high = mid - 1;
            else if (guess < item)
                low = mid + 1;
        }
        return null;
    }

    public static void main(String[] args) {
        int[] my_array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        System.out.println(binary_search(my_array, 5));
        System.out.println(binary_search(my_array, -1));
    }
}
